package SingleTon;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:38917
 * Date:2025/4/13
 * Time:18:35
 */
public class Lazy {
    private static volatile Lazy lazy = null;
    private static final Object locker = new Object();
    private Lazy() {}
    public static Lazy getLazy() {
        if (lazy == null) {
            synchronized (locker) {
                if (lazy == null) {
                    lazy = new Lazy();
                }
            }
        }
        return lazy;
    }

    public static void main(String[] args) {
        Lazy lazy1 = Lazy.getLazy();
        Lazy lazy2 = Lazy.getLazy();
        //true
        System.out.println(lazy1.equals(lazy2));
    }
}
